/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.activity.figure;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;

/**
 * view of an AcceptEventAction
 *
 * @author Gilles Cannenterre
 * @since 2 avr. 07
 */
public class AcceptEventActionFigure extends ActionFigure {

	public AcceptEventActionFigure() {
		super();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.draw2d.Figure#paintBorder(org.eclipse.draw2d.Graphics)
	 */
	@Override
	protected void paintBorder(Graphics graphics) {
		graphics.pushState();
		graphics.setAntialias(SWT.ON);
		Rectangle actionArea = getBounds();
		int height = actionArea.height-1;
		int width = actionArea.width-1;
		int x = getLocation().x;
		int y = getLocation().y;
			
		// Calculate points 
		Point edge = new Point(x+height/2, y+height/2);
		Point point1 = new Point(x , y);
		Point point2 = new Point(x+width , y);
		Point point3 = new Point(x+width , y+height);
		Point point4 = new Point(x , y+height);
				
		// Draw action
		graphics.setForegroundColor(getBorderColor());
		graphics.drawLine(point1, point2);
		graphics.drawLine(point2, point3);
		graphics.drawLine(point3, point4);
		graphics.drawLine(point4, edge);
		graphics.drawLine(edge, point1);
		graphics.popState();
	}

	/* (non-Javadoc)
	 * @see com.cea.papyrus.core.common.figures.NodeFigure#paintFigure(org.eclipse.draw2d.Graphics)
	 */
	@Override
	public void paintFigure(Graphics graphics) {}

	/* (non-Javadoc)
	 * @see com.cea.papyrus.core.diagram.activity.figure.ActionFigure#setBounds(org.eclipse.draw2d.geometry.Rectangle)
	 */
	@Override
	public void setBounds(Rectangle rect) {
		actionNameOffset = rect.height/2;
		actionNameLocationDelta = actionNameOffset;
		super.setBounds(rect);
	}

}
